<template>
  <div>
    <div class="el-container card-container" :class="{'active':activeIndex==index}" v-for="(item,index) in data"
         @click="handleClick(index)"
    >
      <div class="card-text">
        <p class="card-title">{{ item.name }}</p>
      </div>
    </div>
  </div>

</template>

<script>
export default {
  props: {
    data: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      activeIndex: 0
    }
  },
  methods: {
    handleClick(index) {
      this.activeIndex = index
      this.$emit('handleClick', index)
    }
  }
}
</script>

<style lang="scss" scoped>
.card-container {
  display: flex;
  padding: 12px 20px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  margin-bottom: 10px;
  cursor: pointer;
  background:#FAFAFA;
}
.card-title{
  font-size:14px;
  margin:0px;
}
.active {
  border-color: #2979ff;
  background: #e4eeff;
}

.card-num {
  color: #2979ff
}
</style>
